#ifndef ROUTEMAPDRAW_H
#define ROUTEMAPDRAW_H
#include "main.h"
#include "routemap.h"
#include <cairo/cairo.h>
#ifndef M_PI
//#define M_PI 3.14159262
#endif
using namespace Gtk;
using namespace vectorMap;

namespace drawables{
namespace vectorMap{

struct color3{
    double r, g, b;

};

struct MapDrawable{
	MapObject* subject;
	color3 color;
	MapDrawable(MapObject* s):subject(s)
	{
		color = {1,1,1};
	};
	virtual void draw(Cairo::RefPtr<Cairo::Context> cr);	
};
	
		
class RouteMapDraw : public Gtk::DrawingArea{
    protected:
    vector<MapDrawable*> thingsToDraw;

    Cairo::RefPtr<Cairo::ImageSurface> mapBackground;
    /** background showing all the nodes&vertices
      * this to prevent unnecessary redrawing
      */
    public:
        Mutex mutex;
        /** Default constructor */
        RouteMapDraw(RouteMap* map);
        /** Default destructor */
        virtual ~RouteMapDraw();
        vector<color3> nodeColors;
//        virtual bool on_draw (const Cairo::RefPtr< Cairo::Context >& cr);
    protected:
        virtual bool on_draw(GdkEventExpose* gee);


/** \brief
  * redraws the background with nodes and vertices
  * this should only be necessary on load or resize
*/
        virtual bool redrawBackgroundMap();

        /** DrawPath
        virtual function called to draw each \c Path.
        \c context has already been moved to \c node->place
        */
        virtual void drawPath(Node* node, Path* path, Cairo::RefPtr<Cairo::Context> context);
        /** DrawNode
        virtual function called to draw each \c Node.
        \c context has already been moved to \c node->place
        */
        virtual void drawNode(Node* node, Cairo::RefPtr<Cairo::Context> context);

        virtual void beforeDraw(Cairo::RefPtr<Cairo::Context> cr){};
        /** invoked before the map is drawn but after it is scaled and translated. So drawingfunctions take the same coordinates as found in the map
        */
        virtual void afterDraw(Cairo::RefPtr<Cairo::Context> cr){};
        RouteMap* map;
    public:
		virtual void addDrawable(MapDrawable* drawable);
};
}//NAMESPACE vectormap
}//namepace drawables

#endif // ROUTEMAPDRAW_H